﻿using System.Collections.Generic;
using System.Linq;
using BestEasyCMS.Core.NPoco;
using BestEasyCMS.Framework.Pageing;
using BestEasyCMS.Framework.Querying;
using BestEasyCMS.Framework.UnitOfWork;
using BestEasyCMS.Model.IRepository.Security;
using BestEasyCMS.Model.Security;
using BestEasyCMS.Repository.Base;
using NPoco;

namespace BestEasyCMS.Repository.Security
{
    public class RoleRepository : RepositoryBase<Role, long>, IRoleRepository
    {
        #region 字段
        private readonly IDbBase _dbBase;
        private readonly IUserRepository _userRepository;
        #endregion

        #region 构造函数
        public RoleRepository(IDbBase dbBase, IUnitOfWork uow, IUserRepository userRepository)
            : base(dbBase, uow)
        {
            _dbBase = dbBase;
            _userRepository = userRepository;
        }

        #endregion

        #region 重写方法
        #endregion

        #region 扩展方法
        public IEnumerable<Role> ExecuteProc(Query query)
        {
            var sqlModel = new SqlModel();
            query.TranslateInto(sqlModel);
            return _dbBase.ExecuteProcedure<Role>(sqlModel.SqlCommand, sqlModel.SqlParameters);
        }
        #endregion

        #region 私有方法

        private void GetChilren(IEnumerable<Role> roles, int depth, long parentId)
        {
            var result = roles.Where(p => p.Id == parentId).ToList();
            if (result.Any())
            {


            }
        }

        #endregion
    }


}
